//
//  IMISoundRecorder.h
//  IMISound
//
//  Created by Travis on 09-9-8.
//  Copyright 2009 Exmart. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioQueue.h>
#import <AudioToolbox/AudioFile.h>

#define NUM_BUFFERS 3
#define SECONDS_TO_RECORD 10


typedef struct
	{
		AudioStreamBasicDescription  dataFormat;
		AudioQueueRef                queue;
		AudioQueueBufferRef          buffers[NUM_BUFFERS];
		AudioFileID                  audioFile;
		SInt64                       currentPacket;
		bool                         recording;    
	} RecordState;

typedef struct
	{
		AudioStreamBasicDescription  dataFormat;
		AudioQueueRef                queue;
		AudioQueueBufferRef          buffers[NUM_BUFFERS];
		AudioFileID                  audioFile;
		SInt64                       currentPacket;
		bool                         playing;
	} PlayState;


@interface IMISoundRecorder : NSObject {
	RecordState recordState;
    PlayState playState;
    CFURLRef fileURL;
}

- (BOOL)getFilename:(char*)buffer maxLenth:(int)maxBufferLength;
- (void)setupAudioFormat:(AudioStreamBasicDescription*)format;
- (void)recordPressed:(id)sender;

- (void)startRecording;
- (void)stopRecording;


@end